home *** CD-ROM | disk | FTP | other *** search
- program timestmp ;
-
- { The function reads the internal clock and returns a string
- of the form "July 5, 1984 9:30am" which is useful for
- headings on listings and reports. }
-
- type
- stdstr = string [80] ;
-
- RecPack = record
- AX, BX, CX, DX, BP, SI, DI, DS, ES, FLAG : integer ;
- end ;
-
- var
- regs : RecPack ;
- ch : char ;
-
- function StrInt(n : integer) : stdstr ;
- { return a string with the integer in ASCII }
- var
- s : string [6] ;
- begin
- str(n,s) ;
- StrInt := s ;
- end ;
-
- procedure CallDos(fcn : integer) ; { execute DOS fcn # call }
- begin
- with regs do
- begin
- AX := fcn ;
- MsDos(regs) ;
- end ; { with }
- end ;
-
- function kbin : char ;
- { returns key value entered at kbd immediately;
- no display, handle extended codes. }
- var
- c : char ;
- n : integer ;
-
- begin
- CallDos($800) ; { DOS pg D-8 }
- n := Lo(regs.AX) ;
- if n = 25 then
- begin { ^Y to halt }
- writeln ('^Y program halting. What is condition of open files?') ;
- delay (200) ;
- halt ;
- end ;
- if n = 0 then
- begin { ext code }
- CallDos($800) ;
- n := Lo(regs.AX) ;
- if n > 127 then n := n - 124 ;
- n := n + 128 ;
- end ; { ext }
- kbin := chr(n) ;
- end ;
-
- function timestamp : stdstr ;
- { return string of "MON DAY YEAR TIME" }
- type
- mot = array [1..12] of string [3] ;
- const
- mon : mot = ( 'JAN','FEB','MAR','APR','MAY','JUN',
- 'JUL','AUG','SEP','OCT','NOV','DEC' ) ;
- var
- tsret : stdstr ;
- hr : integer ;
- ampm : string [2] ;
-
- begin
- CallDos($2A00) ;
- with regs do
- begin
- tsret := mon[Hi(DX)] + ' ' + StrInt(Lo(DX)) + ',' + StrInt(CX) + ' ' ;
- CallDos($2C00) ;
- hr := Hi(CX) ;
- if hr > 12 then
- begin
- hr := hr - 12 ;
- ampm := 'pm' ;
- end
- else
- ampm := 'am' ;
- timestamp := tsret + (StrInt(hr)) + ':' + (StrInt(Lo(CX))) + ampm ;
- end ; { with }
- end ;
-
- begin
- writeln ('Demonstration of the TIMESTAMP function: ',timestamp) ; writeln ;
- writeln ('The following demonstrates kbin vs keypress (entering q will quit)');
- repeat
- writeln (' using kbin to get extended codes') ;
- ch := kbin ;
- writeln (ch, ord(ch):4) ;
- writeln ( 'Using read(kbd,ch)') ;
- read (kbd,ch) ;
- writeln (ch, ord(ch):4) ;
- until ch = 'q' ;
- end.
-
-
-
-
-
-
-